import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

//学习flutter 的一些简单控件

class SimpleView extends StatefulWidget {
  SimpleView({Key key, this.title}) : super(key: key);

  final String title;

  @override
  State<StatefulWidget> createState() {
    return _MySimpleView();
  }
}

class _MySimpleView extends State<SimpleView> {
  int _counter = 0;
  TextEditingController _editingController;
  String phone;

  @override
  void initState() {
    super.initState();
    _editingController = TextEditingController(text: "phone");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Text.rich(TextSpan(children: [
              TextSpan(text: "tel:"),
              TextSpan(
                  text: "18728888305", style: TextStyle(color: Colors.blue)),
              WidgetSpan(
                  child: Image(
                      image: AssetImage("assets/images/app_logo.png"),
                      width: 10,
                      height: 10))
            ])),
            TextField(
              controller: _editingController,
              decoration: InputDecoration(
                  hintText: "please input", border: OutlineInputBorder()),
              inputFormatters: [
                WhitelistingTextInputFormatter.digitsOnly,
                LengthLimitingTextInputFormatter(11)
              ],
              obscureText: true,
            ),
            Image(
              image: AssetImage("assets/images/app_logo.png"),
              width: 50,
              height: 50,
            ),
            Image.asset(
              "assets/images/app_logo.png",
              width: 60,
              height: 60,
            ),
            //加载网络图片
            Image(
              image: NetworkImage(
                  "https://www.baidu.com/img/pc_2e4ef5c71eaa9e3a3ed7fa3a388ec733.png"),
              width: 200,
              height: 50,
            ),
            //圆形控件
            ClipOval(
                child: Image.asset(
              "assets/images/app_logo.png",
              width: 50,
              height: 50,
            )),
            //容器
            Container(
              width: 50,
              height: 50,
              decoration: BoxDecoration(
                  image: DecorationImage(
                      image: NetworkImage(
                          "https://www.rongcloud.cn/docs/assets/img/index/icon_home_1.png")),
                  shape: BoxShape.circle),
            ),
            //图标
            Icon(Icons.forward, color: Colors.pink, size: 50),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
